package xpn.platform.modules.todo.todolink;

import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import xpn.platform.modules.todo.common.AbstractLink;
import xpn.platform.modules.todo.common.TodoStateEnum;

import javax.persistence.Entity;
import javax.persistence.PrePersist;
import javax.persistence.PreUpdate;
import javax.persistence.Table;

/**
 * 待办事项链接
 *
 * @author zyk Sep 5, 2017
 */
@Entity
@Table(name = "td_todo_link")
@Getter
@Setter
@EqualsAndHashCode(callSuper = false)
public class TodoLink extends AbstractLink {
    private static final long serialVersionUID = -1996008179442119707L;
    private TodoStateEnum state;



    @PrePersist
    @PreUpdate
    public void onPreSave() {
        if (this.getState() == null) {
            this.setState(TodoStateEnum.UNREADED);
        }
    }
}
